window.onload = function() {
    //显示领取人列表
    for (var i = 0; i < peoplelist.length; i++) {
        var img = peoplelist[i].headimg;
        var name = peoplelist[i].headname;
        var time = peoplelist[i].time;
        var money = peoplelist[i].money;
        showPersonList(img, name, time, money)
    }
    var numon = parseInt($("#getNum").html());
    setInterval(addNum, 2000);
    function addNum() {
        numon++;
        $("#getNum").html(numon);
    }

    countTime();
}

// 倒计时
function countTime() {
    //获取当前时间
    var myDate = new Date();
    var now = myDate.getTime();
    //设置截止时间
    var str = "2019/12/30 00:00:00";
    var endDate = new Date(str);
    var end = endDate.getTime();
    //时间差
    var leftTime = end - now;
    //定义变量 h,m,s保存倒计时的时间
    var h, m, s;
    if (leftTime >= 0) {
        h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
        m = Math.floor(leftTime / 1000 / 60 % 60);
        s = Math.floor(leftTime / 1000 % 60);
        if (h < 10) {
            h = "0" + h;
        }
        if (m < 10) {
            m = "0" + m;
        }
        if (s < 10) {
            s = "0" + s;
        }
    }
    //将倒计时赋值到div中
    $("#questionTime").html(h + ":" + m + ":" + s);
    //递归每秒调用countTime方法，显示动态时间效果
    setTimeout(countTime, 1000);
}

// 领取人滚动js
var scrtime;
$("#scrollPeople").hover(function() {
    clearInterval(scrtime);
}, function() {
    scrtime = setInterval(function() {
        var ul = $("#scrollPeople ul");
        var liHeight = ul.find("li:last").height();
        ul.animate({
            marginTop: liHeight + 20 + "px"
        }, 500, function() {
            ul.find("li:last").prependTo(ul)
            ul.find("li:first").hide();
            ul.css({
                marginTop: 0
            });
            ul.find("li:first").fadeIn(300);
        });
    }, 2000);
}).trigger("mouseleave");

//随机领取人列表
function showPersonList(img, name, time, money) {
    var user = '';
    user += '<li>';
    user += '<div class="people">';
    user += '<img src="' + img + '">';
    user += '<div class="people_name"><p>' + name + '<\/p><span>' + time + '<\/span><\/div>';
    user += '<\/div>';
    user += '<div class="money"><span>' + money + '</span></div>';
    user += '<\/li>';
    var u = $(".user_infor");
    $(".newhbget_list ul").append($(user))
}

var peoplelist = [{
    headimg: "https://q.qlogo.cn/qqapp/1104718115/5CD9B7ACD34332B8DA145BE3DE4C44FB/100",
    headname: "有你真好",
    time: "09:30",
    money: "领取1张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/685AA36438DDD7E0EB55D0C18097CA1C/100",
    headname: "冰冰的👠",
    time: "10:34",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/DDA36344FDAF8DF2BFDD8F3DAEDE5B74/100",
    headname: "珍珠",
    time: "13:09",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/E2348DFF85AE861D17451BDDC0432809/100",
    headname: "小贝尔",
    time: "13:34",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/1656EDDA7E648DD32E862460EE92E1C5/100",
    headname: "蜡笔小新",
    time: "14:58",
    money: "领取1张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/29DBC6217FA0B06ABC25C70FE260221F/100",
    headname: "HappyAll",
    time: "15:27",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/72763DE05338B738EEA4D9FBEFD8DBBF/100",
    headname: "多多",
    time: "16:11",
    money: "领取3张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/9CFD84D74ABF5141EA8F6B73BD06C3E1/100",
    headname: "大华@",
    time: "16:10",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/772D04D9EB8E70A961A1D5CABBCF293A/100",
    headname: "温纳尔",
    time: "18:59",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/BA6DA5237D4175DDC750553561F219B7/100",
    headname: "🙊小猴",
    time: "19:01",
    money: "领取1张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/25217BFE51A1B8A16160A9F43837A86F/100",
    headname: "奋斗",
    time: "19:20",
    money: "领取3张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/198FD85BC7EFBCCB5C73AE4FEB633560/100",
    headname: "13566789034",
    time: "19:29",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/02305E433C97C724931A79F8FB04FE50/100",
    headname: "雨天飘叶",
    time: "19:47",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/48BE3B50C3E9847242626FF9A07C3317/100",
    headname: "总有刁民想..",
    time: "19:56",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/5283BB3808A16D227AC03DC4374F77C6/100",
    headname: "思思",
    time: "20:28",
    money: "领取4张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/BE2BFD6D743F815AC7A8FA974E40D4FC/100",
    headname: "向☀阳",
    time: "20:37",
    money: "领取3张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/C54D6E68485F84A86822CF7E473A93EC/100",
    headname: "天使的眼泪",
    time: "20:41",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/2316567F52712C775048DB02BF5C261C/100",
    headname: "汽车商",
    time: "20:45",
    money: "领取3张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/D1A596E47C0AA279BA8BB9BAAC02CC44/100",
    headname: "A股神",
    time: "21:19",
    money: "领取2张"
}, {
    headimg: "https://q.qlogo.cn/qqapp/1104718115/189955F05F482DE956480DB66B07E4DC/100",
    headname: "大道",
    time: "21:54",
    money: "领取2张"
}];
